<?php
  /**
   * @author EVANDRO DE OLIVEIRA.
   * @category VIEW
   * @package VIEWS/SCRIPTS/PAISES.
   * @since 17/06/2012.
   * @last_update 17/06/2012.
   * @copyright 2012.
   * @version 1.0.
   *
   */
?>
<script type="text/javascript">
  $(function(){
    $("input:text:eq(0):visible").focus();
  });
</script>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="content-view" id="teste">
  <tr>
    <td id="messenger" colspan="2"><?php echo $this->flashMessage();?></td>
  </tr>
  <tr>
    <td align="left" class="comp-title">CADASTRO DE <?php echo $this->strTitleP?></td>  
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="center" colspan="2" style="">
      <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%" class="content-form">
        <tr>
          <td class="space-bottom"></td>
        </tr>
        <tr>
          <td>
            <form name="form_add" method="post" action="" id="form_add">
              <table border="0" align="center" cellpadding="0" cellspacing="0">
                <?php 
                  //Core_Commons::debugging($this->request->ds_pais);
                  $intId = 0;
                  $strName = '';
                  foreach($this->arrColunas as $arrColunas){
                    foreach($arrColunas as $strKey => $arrValues){
                      if($strKey !== 'idPais' && $strKey != 'dt_insercao'){
                        switch($arrValues['DATA_TYPE']){
                          case 'varchar':
                            if($arrValues['LENGTH'] <= 5)
                              $intWidth = 50;
                            elseif($arrValues['LENGTH'] > 5 && $arrValues['LENGTH'] <= 50)
                              $intWidth = 120;
                            else
                              $intWidth = 230;
                            
                            $strCampo = $this->input('text', $strKey, $strKey , $this->request->$strKey, true, '', $arrValues['LENGTH'], '', "width: {$intWidth}px;");
                          break;
                          
                          case 'tinyint':
                            $strCampo = $this->comboBox($strKey, '', array('1' => 'Ativo', '0' => 'Inativo'), $this->request->$strKey);
                          break;
                          
                          case 'date':
                          case 'datetime':  
                            $strCampo = $this->input('text', $strKey, $strKey , date("d/m/Y"), false, '', '', '10', "width: 80px;");
                          break;
                          
                          default:
                            $strCampo = $this->input('text', $strKey, $strKey , $this->request->$strKey, true, '', $arrValues['LENGTH'], '', "width: {$intWidth}px;");
                          break;  
                        }
                        
                        $strLabel = preg_replace('[cao]', 'ção', ucfirst(substr($strKey, 3))); 
                        ?>
                        <tr>
                          <td align="right" class="label"><?php echo $strLabel?>:</td>  
                          <td align="left" class="space-bottom">
                            <?php echo $strCampo?>
                          </td>                      
                        </tr>
                        <?php
                      }
                      elseif($strKey == 'idPais'){
                      	$intId = $this->request->$strKey;
                      	$strName = $strKey;
                      }	
                    }
                  }
                ?>
                <tr>  
                  <td align="center" colspan="3">
                    <?php 
                      echo $this->input('submit', 'save', 'boton', 'Cadastrar', true);
                      echo'<span>&nbsp;</span>';
                      echo $this->input('button', 'cancel', 'boton', 'Cancelar', true, '', '', '', '', "onclick=\"window.location='list'\"");
                      echo $this->input('hidden', $strName, $strName , $intId, true);
                    ?>
                  </td>
                </tr>
              </table>
            </form>
          </td>
        </tr>
      </table>
    </td>
  </tr>  
</table>